package threading;

public class ThreadDemo10 {
    public static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {
        //boolean isQuit = false; //变量捕获语法规则
        Thread t = new Thread(() -> {
            while(!isQuit) {
                System.out.println("hello t");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("t 线程中止");
        });
        t.start();
        Thread.sleep(3000);
        isQuit = true;
    }
}